﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>采购订单详情</title>
    <link href="//unpkg.com/layui@2.10.1/dist/css/layui.css" rel="stylesheet">
    <style>
        .detail-container {
            padding: 20px;
        }

        .detail-section {
            margin-bottom: 20px;
            border-bottom: 1px solid #eee;
            padding-bottom: 15px;
        }

            .detail-section h3 {
                margin-bottom: 15px;
                color: #333;
            }

        .detail-item {
            margin-bottom: 10px;
            display: flex;
        }

        .detail-label {
            width: 120px;
            font-weight: bold;
            color: #666;
        }

        .detail-value {
            flex: 1;
        }
    </style>
</head>
<body>
    <div class="layui-card detail-container">
        <div class="layui-card-header">
            <h2>采购订单详情</h2>
        </div>
        <div class="layui-card-body">
            <div class="detail-section">
                <h3>基本信息</h3>
                <table>
                    <tr>
                        <td>
                            <div class="detail-item">
                                <div class="detail-label">采购单号:</div>
                                <div class="detail-value" id="orderCode"></div>
                            </div>
                        </td>
                        <td>
                            <div class="detail-item">
                                <div class="detail-label">采购主题:</div>
                                <div class="detail-value" id="getMaintitle"></div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="detail-item">
                                <div class="detail-label">采购日期:</div>
                                <div class="detail-value" id="saleDate"></div>
                            </div>
                        </td>
                        <td>
                            <div class="detail-item">
                                <div class="detail-label">关联销售订单:</div>
                                <div class="detail-value" id="joinShouOrderid"></div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="detail-item">
                                <div class="detail-label">供应商:</div>
                                <div class="detail-value" id="supplierName"></div>
                            </div>
                        </td>
                        <td>
                            <div class="detail-item">
                                <div class="detail-label">联系人:</div>
                                <div class="detail-value" id="lianName"></div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="detail-item">
                                <div class="detail-label">联系电话:</div>
                                <div class="detail-value" id="lianPhone"></div>
                            </div>
                        </td>
                        <td>
                            <div class="detail-item">
                                <div class="detail-label">采购部门:</div>
                                <div class="detail-value" id="byDepart"></div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="detail-item">
                                <div class="detail-label">采购人员:</div>
                                <div class="detail-value" id="byName"></div>
                            </div>
                        </td>
                        <td>
                            <div class="detail-item">
                                <div class="detail-label">联系方式:</div>
                                <div class="detail-value" id="phoneNumber"></div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="detail-item">
                                <div class="detail-label">关联项目:</div>
                                <div class="detail-value" id="joinProject"></div>
                            </div>
                        </td>
                        <td>
                            <div class="detail-item">
                                <div class="detail-label">结算方式:</div>
                                <div class="detail-value" id="suanType"></div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="detail-item">
                                <div class="detail-label">交付地址:</div>
                                <div class="detail-value" id="address"></div>
                            </div>
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>
                            <div class="detail-item">
                                <div class="detail-label">备注:</div>
                                <div class="detail-value" id="remember"></div>
                            </div>
                        </td>
                        <td></td>
                    </tr>
                </table>
                
                
                
                
                
                
            </div>

            <div class="detail-section">
                <h3>财务信息</h3>
                <div class="detail-item">
                    <div class="detail-label">总金额:</div>
                    <div class="detail-value" id="sumMoney"></div>
                </div>
                <div class="detail-item">
                    <div class="detail-label">已付金额:</div>
                    <div class="detail-value" id="yfuMoney"></div>
                </div>
                <div class="detail-item">
                    <div class="detail-label">已到票金额:</div>
                    <div class="detail-value" id="ydpMoney"></div>
                </div>
            </div>

            <div class="detail-section">
                <h3>状态信息</h3>
                <div class="detail-item">
                    <div class="detail-label">审批状态:</div>
                    <div class="detail-value" id="shenpStuct"></div>
                </div>
                <div class="detail-item">
                    <div class="detail-label">付款状态:</div>
                    <div class="detail-value" id="rukuStuct"></div>
                </div>
                <div class="detail-item">
                    <div class="detail-label">入库状态:</div>
                    <div class="detail-value" id="rukuStuct2"></div>
                </div>
                <div class="detail-item">
                    <div class="detail-label">到票状态:</div>
                    <div class="detail-value" id="dpiaoStuct"></div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-primary" onclick="window.history.back()">返回</button>
                </div>
            </div>
        </div>
    </div>

    <script src="//unpkg.com/layui@2.10.1/dist/layui.js"></script>
    <script>
        layui.use(['jquery'], function(){
            var $ = layui.jquery;

            // 从URL参数中获取数据
            function getQueryParam(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return decodeURIComponent(r[2]);
                return null;
            }

            // 解析URL中的data参数
            var dataParam = getQueryParam('data');
            if (dataParam) {
                try {
                    var rowData = JSON.parse(dataParam);
                    // 填充数据到页面
                    $('#orderCode').text(rowData.orderCode || '');
                    $('#getMaintitle').text(rowData.getMaintitle || '');
                    $('#supplierName').text(rowData.supplierName || '');
                    $('#saleDate').text(formatDate(rowData.saleDate) || '');
                    $('#byDepart').text(rowData.byDepart || '');
                    $('#joinShouOrderid').text(rowData.joinShouOrderid || '');
                    $('#lianName').text(rowData.lianName || '');
                    $('#byName').text(rowData.byName || '');
                    $('#sumMoney').text(rowData.sumMoney || '');
                    $('#yfuMoney').text(rowData.yfuMoney || '');
                    $('#ydpMoney').text(rowData.ydpMoney || '');
                    $('#lianPhone').text(rowData.lianPhone || '');
                    $('#phoneNumber').text(rowData.phoneNumber || '');
                    $('#joinProject').text(rowData.joinProject || '');
                    $('#suanType').text(rowData.suanType || '');
                    $('#address').text(rowData.address || '');
                    $('#remember').text(rowData.remember || '');

                    // 审批状态转换
                    var shenpStuct = rowData.shenpStuct;
                    var shenpStuctText = '';
                    if(shenpStuct == 1) shenpStuctText = '待审批';
                    else if(shenpStuct == 2) shenpStuctText = '审批中';
                    else if(shenpStuct == 3) shenpStuctText = '已通过';
                    else if(shenpStuct == 4) shenpStuctText = '已拒绝';
                    $('#shenpStuct').text(shenpStuctText);

                    $('#rukuStuct').text(rowData.rukuStuct || '');
                    $('#rukuStuct2').text(rowData.rukuStuct || '');
                    $('#dpiaoStuct').text(rowData.dpiaoStuct || '');
                } catch (e) {
                    console.error('解析数据失败:', e);
                }
            }

            // 格式化日期
            function formatDate(dateStr) {
                if (!dateStr) return '';

                const date = new Date(dateStr);
                const year = date.getFullYear();
                const month = String(date.getMonth() + 1).padStart(2, '0');
                const day = String(date.getDate()).padStart(2, '0');
                const hours = String(date.getHours()).padStart(2, '0');
                const minutes = String(date.getMinutes()).padStart(2, '0');
                const seconds = String(date.getSeconds()).padStart(2, '0');

                return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
            }
        });
    </script>
</body>
</html>
